package com.df.bpm.utils.businessViewer.inputsDialogServices;

import com.df.bpm.entity.BusinessInputs;
import com.df.bpm.utils.businessViewer.Main;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity;
import org.springframework.web.client.RestTemplate;


public class BusinessInputsService {


    public Integer updateInput(BusinessInputs businessInputs) {
        if(businessInputs.getBusinessInformationIndex()!=null
                && businessInputs.getBusinessEntityIndex()!=null
        ){
            RestTemplate restTemplate = new RestTemplate();
            String url=Main.server+"businessInputs/update";
            HttpEntity<BusinessInputs> request = new HttpEntity<>(businessInputs, null);
            ResponseEntity<?> response = restTemplate.exchange(
                    url,
                    HttpMethod.POST,
                    request, // 或者使用 HttpEntity 来添加请求头等信息
                    Integer.class
            );
            return (Integer) response.getBody();
        }
        return null;
    }

    public Integer delete(Integer businessInputsIndex) {
        if(businessInputsIndex!=null){
            RestTemplate restTemplate = new RestTemplate();
            String url=Main.server+"businessInputs/delete?businessInputsIndex="+businessInputsIndex;
            ResponseEntity<?> response = restTemplate.exchange(
                    url,
                    HttpMethod.GET,
                    null, // 或者使用 HttpEntity 来添加请求头等信息
                    Integer.class
            );
            return (Integer) response.getBody();
        }
        return null;
    }
}
